package com.xo.user.controller;

import com.xo.common.Result.ResultResponse;
import com.xo.common.pojo.dto.req.LoginDto;
import com.xo.common.pojo.dto.req.RegisterDto;
import com.xo.user.service.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/login")
@Tag(name = "用户登录")
public class LoginController {

    @Resource
    private LoginService loginService;

    @PostMapping("/register")
    @Operation(summary = "账号注册", description = "账号注册")
    public ResultResponse<Object> register(@Validated @RequestBody RegisterDto registerDto) {
        return loginService.register(registerDto);
    }

    @PostMapping
    @Operation(summary = "用户登录", description = "用户登录")
    public ResultResponse<Object> login(@RequestBody LoginDto loginDto){
        return loginService.login(loginDto);
    }


}
